package com.tb.service;

import com.tb.mapper.ItemsMapper;
import com.tb.model.Items;
import com.tb.model.ItemsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: wangguichun
 * @create: 2018-04-13 11:09
 **/

@Service
public class ItemService {

    @Autowired
    ItemsMapper itemsMapper;

    public Items getItemsById(int i) {
        Items items = itemsMapper.selectByPrimaryKey(i);

        System.out.println(items);

        return items;

    }

    public Items getItems() {

//        itemsMapper.

        ItemsExample example = new ItemsExample();
        ItemsExample.Criteria criteria = example.createCriteria();
        criteria.andPriceLessThan((float) 4000);


        List<Items> list = itemsMapper.selectByExample(example);
        for (Items items : list) {
            System.out.println(items.getName());
        }



        return list.get(0);
    }
}
